package com.enation.app.shop.front.policyInsurance.service.impl;

import com.enation.app.shop.front.policyInsurance.entity.SysArea;
import com.enation.app.shop.front.policyInsurance.service.JAreaManageMapper;
import com.enation.framework.database.IDaoSupport;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class AreaManageService implements JAreaManageMapper {
    @Autowired
    private IDaoSupport iDaoSupport;
    @Override
    public List<SysArea> getProvince() {
        String sql = "select * from sys_area s where s.area_level=1";
        return iDaoSupport.queryForList(sql);
    }

    @Override
    public List<SysArea> getCity(int province_id) {
        String sql = "select s.city_id,s.area_name from sys_area s where s.region_id=0 and s.village_id=0 and s.province_id=?";
        return iDaoSupport.queryForList(sql,province_id);
    }

    @Override
    public List<SysArea> getRegion(int province_id, int city_id) {
        String sql = "select * from sys_area s where s.area_level=3 and s.province_id=? and s.city_id=?";
        return iDaoSupport.queryForList(sql,province_id,city_id);
    }

    @Override
    public List<SysArea> getStreet(int province_id, int city_id, int region_id) {
        String sql = "select * from sys_area s where s.area_level=4 and s.province_id=? and s.city_id=? and s.region_id=?";
        return iDaoSupport.queryForList(sql,province_id,city_id,region_id);
    }

    @Override
    public List<SysArea> getVillage(int province_id, int city_id, int region_id,int street_id, int village_id) {
        String sql ="select * from sys_area s where s.area_level=5 and s.province_id=? and s.city_id=? and s.region_id=? and s.village_id=?";
        return this.iDaoSupport.queryForList(sql,province_id,city_id,region_id,street_id,village_id);
    }
}
